<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title><th:block th:text="${edit_gamedata != null} ? '游戏数据修改' : '游戏数据添加'"></th:block></title>

    <!-- Bootstrap core CSS -->
    <link th:href="@{/webjars/bootstrap/4.3.1/css/bootstrap.css}" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link th:href="@{/asserts/css/dashboard.css}" rel="stylesheet">
    <!-- 通知栏样式 -->
    <link th:href="@{/asserts/css/notificationBar.css}" rel="stylesheet">
</head>

<body>
<!-- 引入顶部栏 -->
<div th:replace="common/bar::topbar"></div>

<div class="container-fluid">
    <div class="row">
        <!-- 引入通知栏 -->
        <div th:replace="common/bar::NotificationBar"></div>

        <!-- 引入侧边栏 -->
        <div th:replace="common/bar::#sidebar(activeUri='gamedataman')"></div>

        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <h2 th:text="${edit_gamedata != null} ? '游戏数据修改' : '游戏数据添加'"></h2>
            <hr>
            <input type="hidden" name="id" th:if="${edit_gamedata != null}" th:value="${edit_gamedata.id}"> <!-- id -->
            <div class="form-group">
                <label>设备范围</label>
                <input name="devRange" type="text" class="form-control"
                       placeholder="设备范围，A-B表示一个范围从A到B（支持分组），有多个范围请用逗号（支持中英文符号）隔开。"
                       th:value="${edit_gamedata != null} ? ${edit_gamedata.devRange}">
            </div>

            <div class="form-group">
                <label>区服范围</label>
                <input name="regionServerRange" type="text" class="form-control"
                       placeholder="区服范围，A:B表示一个区服（A区B服务器），有多个区服请用逗号隔开，支持中英文符号。"
                       th:value="${edit_gamedata != null} ? ${edit_gamedata.regionServerRange}">
            </div>

            <div class="form-group">
                <label>角色数量</label>
                <input name="nrRole" type="text" class="form-control" oninput="value=value.replace(/[^\d]/g,'')"
                       placeholder="角色数量，即该每台设备应该有几个角色。"
                       th:value="${edit_gamedata != null} ? ${edit_gamedata.nrRole}">
            </div>

            <!--/* 游戏数据 */-->
            <th:block th:if="${gamedata_map != null}">
                <th:block th:each="key : ${gamedata_map.map.keySet()}">
                    <div class="form-group">
                        <label th:text="${gamedata_map.map.get(key).name}"></label>
                        <input th:name="${key}" type="text" class="form-control" th:if="${gamedata_map.map.get(key).limitState == false}"
                               th:value="${edit_gamedata != null} ? ${edit_gamedata.resourceDataMap.get(key)}">
                        <select class="form-control" th:name="${key}" th:id="${key} + '_select'" th:if="${gamedata_map.map.get(key).limitState == true}">
                            <option th:selected="${edit_gamedata != null} ? ${edit_gamedata.resourceDataMap.get(key) == limitEntry.key}"
                                    th:value="${limitEntry.key}" th:each="limitEntry : ${gamedata_map.map.get(key).limit}"
                                    th:text="${limitEntry.value}">
                            </option>
                        </select>
                    </div>
                </th:block>
            </th:block>

            <button type="submit" class="btn btn-primary" th:onclick="'return gamedataSaveOrUpdate(\'' +  ${gamedata_map_json} + '\')'"
                    th:text="${edit_gamedata != null} ? '更新' : '添加'"></button>

        </main>
        <br>
        <br>
        <br>
    </div>
</div>

<!-- 引入公共的js  -->
<div th:replace="common/js::js"></div>
<!-- 自定义的js -->
<script type="text/javascript" th:src="@{/asserts/js/gamedata.js}" ></script>

</body>
</html>